﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerBehaviour : MonoBehaviour
{
    public Dictionary<Vector2, int> GetNearyByCoverScore()
    {
        Collider2D currentCollider = GetComponent<Collider2D>();

        Dictionary<Vector2, int> result = new Dictionary<Vector2, int>();

        foreach (Vector2 direction in new Vector2[] { Vector2.left, Vector2.down, Vector2.right, Vector2.up })
        {
            RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, currentCollider.bounds.size.y, LayerMask.GetMask(StaticDataManager.BLOCK_LAYER));
            if (hit && hit.collider.CompareTag(StaticDataManager.BLOCK_TAG))
            {
                // TODO 根据掩体属性来返回Int值
                result[direction] = 1;
            }
            else
            {
                result[direction] = 0;
            }
        }

        return result;
    }

    public Dictionary<Vector2, GameObject> GetNearbyBlocks()
    {
        Collider2D currentCollider = GetComponent<Collider2D>();

        Dictionary<Vector2, GameObject> result = new Dictionary<Vector2, GameObject>();

        foreach (Vector2 direction in new Vector2[] { Vector2.up, Vector2.down, Vector2.left, Vector2.right })
        {
            RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, currentCollider.bounds.size.x);
            if (hit && hit.collider.CompareTag(StaticDataManager.BLOCK_TAG))
            {
                // TODO 根据掩体属性来返回Int值
                result[direction] = hit.collider.gameObject;
            }
            else
            {
                result[direction] = null;
            }
        }

        return result;
    }
}
